package com.itheima.controller;/**
 *
 */

import com.itheima.domain.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName TestDemo02
 * @Description TODO
 *  @Author $无小白$
 *  @Date 2020/8/24 22:31
 *  @Version 1.0
 **/
public class TestDemo02 {
@Test
    public void test(){
       ApplicationContext ca = new ClassPathXmlApplicationContext("spring.xml");
            /*多例prototype 随被调用而创建*/
        User user2 = ca.getBean("user2", User.class);
        user2.eat();
        /*单例singleton随ioc的生命周期生死存亡*/
        User user1 = ca.getBean("user1", User.class);
        user1.eat();

    ClassPathXmlApplicationContext ca1 = new ClassPathXmlApplicationContext("spring.xml");
    User user4 = ca.getBean("user4", User.class);
    ca1.close();



}

}
